tests: Stop using gtk_window_move
authorMatthias Clasen <mclasen@redhat.com>
Mon, 25 Mar 2019 01:44:31 +0000 (21:44 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 26 Mar 2019 21:55:29 +0000 (17:55 -0400)
It is going away.

tests/animated-resizing.c
tests/meson.build
tests/testgtk.c
tests/testnotebookdnd.c
tests/testpopup.c
tests/testxinerama.c [deleted file]
testsuite/gtk/window.c

index 88c300ef78a5981db7441ba17e7ed0c750bc9647..dd849a4155584602111da2b6e15176fb967bde05 100644 (file)
@@ -207,10 +207,6 @@ main(int argc, char **argv)
   monitor = gdk_display_get_primary_monitor (display);
   gdk_monitor_get_geometry (monitor, &monitor_bounds);
 
-  gtk_window_move (GTK_WINDOW (window),
-                   monitor_bounds.x + (monitor_bounds.width - window_width) / 2,
-                   monitor_bounds.y + (monitor_bounds.height - window_height) / 2);
-
   gtk_widget_show (window);
 
   gtk_main ();
index 23570f6306b56cfd5b0e8a6ef26a881532f867ce..59d48e3f542dc4f82e5662d42941dec4f38ee743 100644 (file)
@@ -89,7 +89,6 @@ gtk_tests = [
   ['testtreesort'],
   ['testverticalcells'],
   ['treestoretest'],
-  ['testxinerama'],
   ['testgrouping'],
   ['testtooltips'],
   ['testexpand'],
index ab22813c20932bc5abd50971005d5953b9ad2053..ab5bf82be79d3829fec2d7d45618fc3bb1c36df4 100644 (file)
@@ -5253,14 +5253,8 @@ size_allocate_callback (GtkWidget     *widget,
 {
   GtkWidget *label = data;
   gchar *msg;
-  gint x, y;
 
-  gtk_window_get_position (GTK_WINDOW (widget), &x, &y);
-
-  msg = g_strdup_printf ("size: %d x %d\n"
-                         "position: %d, %d",
-                         allocation->width, allocation->height,
-                         x, y);
+  msg = g_strdup_printf ("size: %d x %d\n", allocation->width, allocation->height);
 
   gtk_label_set_text (GTK_LABEL (label), msg);
 
@@ -5333,31 +5327,6 @@ set_size_request_callback (GtkWidget *widget,
                                w, h);
 }
 
-static void
-set_location_callback (GtkWidget *widget,
-                       gpointer   data)
-{
-  gint x, y;
-  
-  get_ints (data, &x, &y);
-
-  gtk_window_move (g_object_get_data (data, "target"), x, y);
-}
-
-static void
-move_to_position_callback (GtkWidget *widget,
-                           gpointer   data)
-{
-  gint x, y;
-  GtkWindow *window;
-
-  window = g_object_get_data (data, "target");
-  
-  gtk_window_get_position (window, &x, &y);
-
-  gtk_window_move (window, x, y);
-}
-
 static void
 resizable_callback (GtkWidget *widget,
                      gpointer   data)
@@ -5478,20 +5447,6 @@ window_controls (GtkWidget *window)
                     control_window);
   gtk_container_add (GTK_CONTAINER (vbox), button);
 
-  button = gtk_button_new_with_label ("Move");
-  g_signal_connect (button,
-                   "clicked",
-                   G_CALLBACK (set_location_callback),
-                   control_window);
-  gtk_container_add (GTK_CONTAINER (vbox), button);
-
-  button = gtk_button_new_with_label ("Move to current position");
-  g_signal_connect (button,
-                   "clicked",
-                   G_CALLBACK (move_to_position_callback),
-                   control_window);
-  gtk_container_add (GTK_CONTAINER (vbox), button);
-
   button = gtk_check_button_new_with_label ("Allow resize");
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
   g_signal_connect (button,
@@ -6613,7 +6568,6 @@ create_main_window (void)
 
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   gtk_widget_set_name (window, "main_window");
-  gtk_window_move (GTK_WINDOW (window), 50, 20);
   gtk_window_set_default_size (GTK_WINDOW (window), -1, 400);
 
   g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
index 13b280658514db3b85efaabd27f379c45fdfc46d..543b8186f3457d008221651d24bc230fde6e9f31 100644 (file)
@@ -79,7 +79,6 @@ window_creation_function (GtkNotebook *source_notebook,
   gtk_container_add (GTK_CONTAINER (window), notebook);
 
   gtk_window_set_default_size (GTK_WINDOW (window), 300, 300);
-  gtk_window_move (GTK_WINDOW (window), x, y);
   gtk_widget_show (window);
 
   return GTK_NOTEBOOK (notebook);
index b496fe5eae756097759361ccd16fcc787a420e12..00a2ca78bf79a3a853b099b9a90adcace9730220 100644 (file)
@@ -17,16 +17,6 @@ place_popup (GtkEventControllerMotion *motion,
              gdouble                   y,
              GtkWidget                *popup)
 {
-  gint width, height, win_x, win_y;
-  GtkWidget *widget;
-
-  widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (motion));
-
-  gtk_window_get_size (GTK_WINDOW (popup), &width, &height);
-  gtk_window_get_position (GTK_WINDOW (widget), &win_x, &win_y);
-  gtk_window_move (GTK_WINDOW (popup),
-                   (int) win_x + x - width / 2,
-                   (int) win_y + y - height / 2);
 }
 
 static gboolean
diff --git a/tests/testxinerama.c b/tests/testxinerama.c
deleted file mode 100644 (file)
index 8701124..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-/* testmultidisplay.c
- * Copyright (C) 2001 Sun Microsystems Inc.
- * Author: Erwann Chenede <erwann.chenede@sun.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-#include <stdlib.h>
-#include <gtk/gtk.h>
-
-static void
-label_set_text_for_monitor (GtkLabel   *label,
-                            GdkMonitor *monitor)
-{
-  GdkRectangle monitor_geom; 
-  gchar *str;
-
-  gdk_monitor_get_geometry (monitor, &monitor_geom);
-
-  str = g_strdup_printf ("<big><span foreground='white' background='black'>"
-                         "%s %s</span></big>\n"
-                         "<i>Width - Height       </i>: (%d,%d)\n"
-                         "<i>Top left coordinate </i>: (%d,%d)\n"
-                         "<i>Primary monitor</i>: %s",
-                         gdk_monitor_get_manufacturer (monitor),
-                         gdk_monitor_get_model (monitor),
-                         monitor_geom.width, monitor_geom.height,
-                         monitor_geom.x, monitor_geom.y,
-                         gdk_monitor_is_primary (monitor) ? "YES" : "no");
-  gtk_label_set_markup (label, str);
-  g_free (str);
-}
-
-static void
-request (GtkWidget      *widget,
-        gpointer        user_data)
-{
-  GdkDisplay *display = gtk_widget_get_display (widget);
-  GdkMonitor *monitor = gdk_display_get_monitor_at_surface (display, 
-                                              gtk_widget_get_surface (widget));
-
-  if (monitor == NULL)
-    gtk_label_set_markup (GTK_LABEL (user_data), 
-                          "<big><span foreground='white' background='black'>Not on a monitor </span></big>");
-  else
-    label_set_text_for_monitor (GTK_LABEL (user_data), monitor);
-}
-
-static void
-monitor_changed_cb (GdkMonitor *monitor,
-                    GParamSpec *pspec,
-                    GtkWidget  *label)
-{
-  request (label, label);
-}
-
-static void
-monitor_added (GdkDisplay *display,
-               GdkMonitor *monitor,
-               gpointer    unused)
-{
-  GtkWidget *window, *label, *vbox, *button;
-  GdkRectangle monitor_geom; 
-
-  gdk_monitor_get_geometry (monitor, &monitor_geom);
-
-  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-      
-  gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
-  gtk_window_move (GTK_WINDOW (window), (monitor_geom.width - 200) / 2 + monitor_geom.x,
-                   (monitor_geom.height - 200) / 2 + monitor_geom.y);
-  
-  label = gtk_label_new (NULL);
-  label_set_text_for_monitor (GTK_LABEL (label), monitor);
-  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 1);
-  gtk_box_set_homogeneous (GTK_BOX (vbox), TRUE);
-  gtk_container_add (GTK_CONTAINER (window), vbox);
-  gtk_container_add (GTK_CONTAINER (vbox), label);
-  button = gtk_button_new_with_label ("Query current monitor");
-  g_signal_connect (button, "clicked", G_CALLBACK (request), label);
-  gtk_container_add (GTK_CONTAINER (vbox), button);
-  button = gtk_button_new_with_label ("Close");
-  g_signal_connect (button, "clicked", G_CALLBACK (gtk_main_quit), NULL);
-  gtk_container_add (GTK_CONTAINER (vbox), button);
-  gtk_widget_show (window);
-
-  g_signal_connect (monitor, "notify",
-                    G_CALLBACK (monitor_changed_cb), label);
-  g_signal_connect_swapped (monitor, "invalidate",
-                            G_CALLBACK (gtk_widget_destroy), window);
-}
-
-int
-main (int argc, char *argv[])
-{
-  GdkDisplay *display;
-  gint i, num_monitors;
-
-  gtk_init ();
-
-  display = gdk_display_get_default ();
-
-  g_signal_connect (display, "monitor-added", G_CALLBACK (monitor_added), NULL);
-
-  num_monitors = gdk_display_get_n_monitors (display);
-  if (num_monitors == 1)
-    g_warning ("The current display only has one monitor.");
-
-  for (i = 0; i < num_monitors; i++)
-    {
-      GdkMonitor *monitor;
-      
-      monitor = gdk_display_get_monitor (display, i);
-      monitor_added (display, monitor, NULL);
-    }
-
-  gtk_main ();
-
-  return 0;
-}
index bb8310c78799649e2767af3fb2e803bb87407832..186570983e64edd91ef58f81f4aa19bbc6a9591d 100644 (file)
@@ -190,18 +190,13 @@ static void
 test_resize_popup (void)
 {
   GtkWidget *window;
-  gint x, y, w, h;
+  gint w, h;
 
   /* testcase for the dnd window */
   window = gtk_window_new (GTK_WINDOW_POPUP);
   gtk_window_set_display (GTK_WINDOW (window), gdk_display_get_default ());
   gtk_window_resize (GTK_WINDOW (window), 1, 1);
-  gtk_window_move (GTK_WINDOW (window), -99, -99);
-
-  gtk_window_get_position (GTK_WINDOW (window), &x, &y);
   gtk_window_get_size (GTK_WINDOW (window), &w, &h);
-  g_assert_cmpint (x, ==, -99);
-  g_assert_cmpint (y, ==, -99);
   g_assert_cmpint (w, ==, 1);
   g_assert_cmpint (h, ==, 1);
 
@@ -210,10 +205,7 @@ test_resize_popup (void)
   g_timeout_add (200, stop_main, NULL);
   gtk_main ();
 
-  gtk_window_get_position (GTK_WINDOW (window), &x, &y);
   gtk_window_get_size (GTK_WINDOW (window), &w, &h);
-  g_assert_cmpint (x, ==, -99);
-  g_assert_cmpint (y, ==, -99);
   g_assert_cmpint (w, ==, 1);
   g_assert_cmpint (h, ==, 1);
 
@@ -260,94 +252,6 @@ test_show_hide (void)
   gtk_widget_destroy (window);
 }
 
-static void
-test_show_hide2 (void)
-{
-  GtkWidget *window;
-  gint x, y, w, h, w1, h1;
-
-  g_test_bug ("696882");
-
-  /* test that hide/show does not affect the size,
-   * even when get_position/move is called
-   */
-
-  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-
-  gtk_widget_show (window);
-
-  g_timeout_add (100, stop_main, NULL);
-  gtk_main ();
-
-  gtk_window_get_position (GTK_WINDOW (window), &x, &y);
-  gtk_window_get_size (GTK_WINDOW (window), &w, &h);
-  gtk_widget_hide (window);
-
-  g_timeout_add (100, stop_main, NULL);
-  gtk_main ();
-
-  gtk_window_get_size (GTK_WINDOW (window), &w1, &h1);
-  g_assert_cmpint (w, ==, w1);
-  g_assert_cmpint (h, ==, h1);
-
-  gtk_window_move (GTK_WINDOW (window), x, y);
-  gtk_widget_show (window);
-
-  g_timeout_add (100, stop_main, NULL);
-  gtk_main ();
-
-  gtk_window_get_size (GTK_WINDOW (window), &w1, &h1);
-  g_assert_cmpint (w, ==, w1);
-  g_assert_cmpint (h, ==, h1);
-
-  gtk_widget_destroy (window);
-}
-
-static void
-test_show_hide3 (void)
-{
-  GtkWidget *window;
-  gint x, y, w, h, w1, h1;
-
-  g_test_bug ("696882");
-
-  /* test that hide/show does not affect the size,
-   * even when get_position/move is called and
-   * a default size is set
-   */
-
-  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-  gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
-
-  gtk_widget_show (window);
-
-  g_timeout_add (100, stop_main, NULL);
-  gtk_main ();
-
-  gtk_window_get_position (GTK_WINDOW (window), &x, &y);
-  gtk_window_get_size (GTK_WINDOW (window), &w, &h);
-  gtk_widget_hide (window);
-
-  g_timeout_add (100, stop_main, NULL);
-  gtk_main ();
-
-  gtk_window_get_size (GTK_WINDOW (window), &w1, &h1);
-  g_assert_cmpint (w, ==, w1);
-  g_assert_cmpint (h, ==, h1);
-
-  gtk_window_move (GTK_WINDOW (window), x, y);
-  gtk_widget_show (window);
-
-  g_timeout_add (100, stop_main, NULL);
-  gtk_main ();
-
-  gtk_window_get_size (GTK_WINDOW (window), &w1, &h1);
-  g_assert_cmpint (w, ==, w1);
-  g_assert_cmpint (h, ==, h1);
-
-  gtk_widget_destroy (window);
-}
-
 int
 main (int argc, char *argv[])
 {
@@ -366,8 +270,6 @@ main (int argc, char *argv[])
   g_test_add_func ("/window/resize", test_resize);
   g_test_add_func ("/window/resize-popup", test_resize_popup);
   g_test_add_func ("/window/show-hide", test_show_hide);
-  g_test_add_func ("/window/show-hide2", test_show_hide2);
-  g_test_add_func ("/window/show-hide3", test_show_hide3);
 
   return g_test_run ();
 }